<template>
	<div style="border: 2px solid black;padding: 30px;">
		<el-table :data="tableData" border style="width: 100%" :default-sort="{ prop: 'date', order: 'descending' }">
			<el-table-column prop="id" label="ID" sortable min-width="180"></el-table-column>
			<el-table-column prop="title" label="title" sortable min-width="180"></el-table-column>
			<el-table-column prop="time" label="time" sortable min-width="180"></el-table-column>
			<el-table-column prop="status" label="status" sortable min-width="180"></el-table-column>
			<el-table-column prop="author" label="author" sortable min-width="180"></el-table-column>
			<el-table-column prop="pageviews" label="pageviews" sortable min-width="180"></el-table-column>
			<el-table-column fixed="right" label="操作" width="100">
				<template slot-scope="scope">
					<el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
					<el-button type="text" size="small">编辑</el-button>
				</template>
			</el-table-column>

			<!-- <el-table-column prop="author" label="author" :formatter="formatter"></el-table-column> -->
		</el-table>
	</div>
</template>

<script>
import { chartAll } from '../api/index';
export default {
	data() {
		return {
			tableData: []
		};
	},
	mounted() {
		chartAll({})
			.then(res => {
				this.tableData = res;
				console.log(this.tableData);
			})
			.catch(err => {
				console.log(err);
			});
	},
	methods: {
		handleClick(row) {
			console.log(row);
		},
		formatter(row) {
			return row.address;
		}
	}
};
</script>
